package com.imooc.long5zb;

import com.imooc.long5zb.exception.CheckException;

import java.util.stream.Stream;

public class CheckUtil {

    private static final String[] INVALID_NAMES = {"admin", "ADMIN", "root", "ROOT"};

    /**
     * 校验名字不含特殊字符
     * @param value
     */
    public static void checkName(String value) {
        Stream.of(INVALID_NAMES).filter(name -> name.equalsIgnoreCase(value))
                .findAny().ifPresent(name -> {
                    throw new CheckException("name", value);
        });
    }
}
